/**
 * Definition for a binary tree node.
 * struct TreeNode {
 *     int val;
 *     struct TreeNode *left;
 *     struct TreeNode *right;
 * };
 */


/**
 * Note: The returned array must be malloced, assume caller calls free().
 */
 void postorder(struct TreeNode* root, int* res, int* resize){
    if(root == NULL) return ;  //递归出口
    postorder(root->left, res, resize);  // 左
    postorder(root->right, res, resize);  // 右
    res[(*resize)++] = root->val;      // 根
    
}
// 树中节点的数目在范围 [0, 100] 内
int* postorderTraversal(struct TreeNode* root, int* returnSize){
    int* res = (int*)malloc(sizeof(int)*200);  //申请返回数组
    if(res == NULL) assert(0);  // malloc失败
    *returnSize = 0;
    postorder(root, res, returnSize);
    return res;
}